﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication
{
    /// <summary>
    /// Test something about type
    /// </summary>
    public class TypeClass
    {
        public const int AConstNum = 100;
        private int _readonlyProperty;
        public int ReadOnlyProperty { get { return _readonlyProperty; } }
        public int AddProperty { get; set; }
        public static TypeClass operator+(TypeClass c1,TypeClass c2)
        {
            TypeClass tc = new TypeClass();
            tc.AddProperty = c1.AddProperty + c2.AddProperty;
            return tc;
        }
        public TypeClass()
        {
            _readonlyProperty = 1;
        }
        public void Read()
        {
            _readonlyProperty = 3;
        }
        public override string ToString()
        {
            return "Just a test class called TypeClass";
        }
        public static explicit operator Int32(TypeClass tc)
        {
            return tc.ReadOnlyProperty;
        }
        public static implicit operator Int64(TypeClass tc)
        {
            return tc.ReadOnlyProperty;
        }
        public int Add(params int[] values)
        {
            int sum = 0;
            foreach (var item in values)
            {
                sum += item;
            }
            return sum;
        }
        public int this[int index]
        {
            get
            {
                return AConstNum * index;
            }
        }
        public int this[int index, bool use]
        {
            get
            {
                if (use)
                {
                    return AConstNum * index;
                }
                else
                {
                    return index;
                }
            }
        }
        public int this[bool use]
        {
            get
            {
                if (use)
                {
                    return AConstNum;
                }
                else
                {
                    return 0;
                }
            }
        }
    }
}
